package com.yida.wy.basic.controller;

import com.mybatisflex.core.paginate.Page;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.wy.basic.domain.WyBasePropertyManagementCompany;
import com.yida.wy.basic.service.IWyBasePropertyManagementCompanyService;
import com.yida.wy.common.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * 物业公司基础信息 控制层。
 *
 * @author lqq
 * @since 1.0
 */
@RestController
@RequestMapping("/wyBasePropertyManagementCompany")
@Api(tags = "物业公司基础信息")
public class WyBasePropertyManagementCompanyController extends BaseController {

    @Resource
    private IWyBasePropertyManagementCompanyService wyBasePropertyManagementCompanyService;

    /**
     * 添加 物业公司基础信息
     *
     * @param wyBasePropertyManagementCompany 物业公司基础信息
     * @return {@code true} 添加成功，{@code false} 添加失败
     */
    @PostMapping("/save")
    @ApiOperation(value = "添加物业公司基础信息", notes = "添加物业公司基础信息")
    public AjaxResult save(@RequestBody WyBasePropertyManagementCompany wyBasePropertyManagementCompany) {
        return toAjax(wyBasePropertyManagementCompanyService.save(wyBasePropertyManagementCompany));
    }


    /**
     * 根据主键删除物业公司基础信息
     *
     * @param id 主键
     * @return {@code true} 删除成功，{@code false} 删除失败
     */
    @DeleteMapping("/remove/{id}")
    @ApiOperation(value = "根据主键删除物业公司基础信息", notes = "根据主键删除物业公司基础信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "companyId", value = "公司ID", required = true)
    })
    public AjaxResult remove(@PathVariable Serializable id) {
        return toAjax(wyBasePropertyManagementCompanyService.removeById(id));
    }


    /**
     * 根据主键更新物业公司基础信息
     *
     * @param wyBasePropertyManagementCompany 物业公司基础信息
     * @return {@code true} 更新成功，{@code false} 更新失败
     */
    @PutMapping("/update")
    @ApiOperation(value = "根据主键更新物业公司基础信息", notes = "根据主键更新物业公司基础信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "companyId", value = "公司ID", required = true),
            @ApiImplicitParam(name = "companyNatureId", value = "公司性质ID"),
            @ApiImplicitParam(name = "companyName", value = "公司名称"),
            @ApiImplicitParam(name = "areaCode", value = "地区编码"),
            @ApiImplicitParam(name = "postalCode", value = "邮政编码"),
            @ApiImplicitParam(name = "contactPerson", value = "企业联系人"),
            @ApiImplicitParam(name = "contactPhone", value = "企业联系人电话号码"),
            @ApiImplicitParam(name = "email", value = "邮箱"),
            @ApiImplicitParam(name = "socialidentityCode", value = "社会统一识别码"),
            @ApiImplicitParam(name = "businessExpiryDate", value = "营业有效期"),
            @ApiImplicitParam(name = "registerCapital", value = "注册资本（100.25）（单位万）"),
            @ApiImplicitParam(name = "establishTime", value = "成立时间"),
            @ApiImplicitParam(name = "landline", value = "座机电话"),
            @ApiImplicitParam(name = "legalRepresentative", value = "法定代表人"),
            @ApiImplicitParam(name = "legalPersonId", value = "法人身份证号"),
            @ApiImplicitParam(name = "engagePeopleNum", value = "从业人员数量"),
            @ApiImplicitParam(name = "projectManagerNum", value = "项目经理人数"),
            @ApiImplicitParam(name = "registerAddress", value = "企业注册地址"),
            @ApiImplicitParam(name = "detailAddress", value = "企业详细地址"),
            @ApiImplicitParam(name = "addressLng", value = "详细地址精度"),
            @ApiImplicitParam(name = "addressLat", value = "详细地址纬度"),
            @ApiImplicitParam(name = "website", value = "企业网址"),
            @ApiImplicitParam(name = "approvalStatus", value = "审批状态:0未审批;1已审批"),
            @ApiImplicitParam(name = "approver", value = "审批人"),
            @ApiImplicitParam(name = "approvalTime", value = "审批时间"),
            @ApiImplicitParam(name = "approvalRemark", value = "审批意见"),
            @ApiImplicitParam(name = "companyProfile", value = "公司简介"),
            @ApiImplicitParam(name = "businessScope", value = "经营范围"),
            @ApiImplicitParam(name = "status", value = "状态:0正常;1关闭"),
            @ApiImplicitParam(name = "cancelReason", value = "取消原因（留待备用）"),
            @ApiImplicitParam(name = "fileCode", value = "文件编码(文件上传统一查询编码)"),
            @ApiImplicitParam(name = "partyOrganizationId", value = "党组织ID")})
    public AjaxResult update(@RequestBody WyBasePropertyManagementCompany wyBasePropertyManagementCompany) {
        return toAjax(wyBasePropertyManagementCompanyService.updateById(wyBasePropertyManagementCompany));
    }


    /**
     * 查询所有物业公司基础信息
     *
     * @return 所有数据
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询所有物业公司基础信息", notes = "查询所有物业公司基础信息")
    public AjaxResult list() {
        return AjaxResult.success(wyBasePropertyManagementCompanyService.list());
    }


    /**
     * 根据物业公司基础信息主键获取详细信息。
     *
     * @param id wyBasePropertyManagementCompany主键
     * @return 物业公司基础信息详情
     */
    @GetMapping("/getInfo/{id}")
    @ApiOperation(value = "根据物业公司基础信息主键获取详细信息", notes = "根据物业公司基础信息主键获取详细信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "companyId", value = "公司ID", required = true)
    })
    public AjaxResult getInfo(@PathVariable Serializable id) {
        return AjaxResult.success(wyBasePropertyManagementCompanyService.getById(id));
    }


    /**
     * 分页查询物业公司基础信息
     *
     * @param page 分页对象
     * @return 分页对象
     */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询物业公司基础信息", notes = "分页查询物业公司基础信息")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true)
    })
    public TableDataInfo page(Page<WyBasePropertyManagementCompany> page) {
        return getDataTable(wyBasePropertyManagementCompanyService.page(page));
    }
}